{%- set separator = ' ' -%}
{{ pillar['headers']['multiline'] -}}
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user    command
{%- for job in jobs | selectattr('enable') %}
{% if job.execution == "exactly" -%}
{% if job.everynminute | to_bool %}*/{{ job.minute }}{% else %}{{ job.minute }}{% endif -%}
{{ separator }}{% if job.everynhour | to_bool %}*/{{ job.hour }}{% else %}{{ job.hour }}{% endif -%}
{{ separator }}{% if job.everyndayofmonth | to_bool %}*/{{ job.dayofmonth }}{% else %}{{ job.dayofmonth }}{% endif -%}
{{ separator }}{{ job.month }}{{ separator }}{{ job.dayofweek }}
{%- else -%}
@{{ job.execution }}
{%- endif -%}
{%- set keep = '' -%}
{%- if job.keep > 0 -%}
{%- set keep = ' -k ' ~ job.keep -%}
{%- endif -%}
{{ separator }}root omv-backup-vm -v {{ job.vmname }} -d {{ job.path }}{{ keep }}{{ ' -p' if job.poweroff | to_bool }}{{ ' -s' if job.samefmt | to_bool }}{{ ' -c' if job.compression | to_bool }}
{%- if not job.sendemail | to_bool -%}
{{ separator }}>/dev/null 2>&1
{%- else -%}
{{ separator }}2>&1 | mail -E -s "Cron{{ ' - ' ~ job.comment | replace('\n', ' ') if job.comment | length > 0 else '' }}" -a "From: Cron Daemon <root>" root >/dev/null 2>&1
{%- endif -%}
{%- endfor -%}
